/** @noSelfInFile **/

import {LocModel} from "../../../base/LocModel";
import {ITexttagAdapter} from "../../adapterInterface/model2/ITexttagAdapter";

export class TexttagAdapter implements ITexttagAdapter {
    createHandle(name: string): any {
        return CreateTextTag();
    }

    destroy(handle: any): void {
        handle_unref(handle);
        DestroyTextTag(handle);
    }

    setColor(handle: any, red: number, green: number, blue: number, alpha: number): void {
        SetTextTagColor(handle, red, green, blue, alpha);
    }

    setPos(handle: any, loc: LocModel, heightOffset: number): void {
        SetTextTagPos(handle, loc.x, loc.y, heightOffset);
    }

    setText(handle: any, s: string, height: number, adjustHeight: boolean): void {
        if (adjustHeight) {
            height = height * 0.0023;
        }
        SetTextTagText(handle, s, height);
    }

    bindHandle(handle: any): void {
        handle_ref(handle);
    }
    equal(handle1: any, handle2: any): boolean {
        return (GetHandleId(handle1) === GetHandleId(handle2))
    }

    isValid(handle: any): boolean {
        if (handle) {
            return true;
        }
        return false;
    }
}
